<?php
/**
 * This is User controller test file. 
 *
 * @copyright     Copyright 2008-2010, LilCake.net
 * @link          http://lilcake.net LilCake.net
 * @package       lil
 * @subpackage    lil.tests.cases.models
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
App::import('Model', 'Lil.User');
/**
 * UserTestCase class
 *
 * @uses          CakeTestCase
 * @package       lil
 * @subpackage    lil.tests.cases.models
 */
class UserTestCase extends CakeTestCase {
/**
 * User property
 *
 * @var object
 * @access public
 */
	var $User = null;
/**
 * fixtures property
 *
 * @var array
 * @access public
 */
	var $fixtures = array(
		'plugin.lil.area', 'plugin.lil.areas_user', 'plugin.lil.user'
	);
/**
 * start method
 *
 * @access public
 * @return void
 */
	function start() {
		// reset variables
		require dirname(dirname(dirname(dirname(__FILE__)))) . DS . 'config' . DS . 'core.php';
		
		parent::start();
		$this->User =& ClassRegistry::init('User');
	}
/**
 * testAuthorInstance method
 *
 * @access public
 * @return void
 */
	function testUserInstance() {
		$this->assertTrue(is_a($this->User, 'User'));
	}
/**
 * testAuthorFind method
 *
 * @access public
 * @return void
 */
	function testUserFind() {
		$results = $this->User->recursive = -1;
		$results = $this->User->find('first');
		$this->assertTrue(!empty($results));

		App::import('Core', 'Security');
		
		$expected = array('User' => array(
			'id'        => 1,
			'admin'     => true,
			'name'      => 'John Doe',
			'email'     => 'john@doe.com',
			'username'  => 'johndoe',
			'passwd'    => Security::hash('admin', null, true),
			'created'   => '2008-01-23 12:34:56',
			'modified'  => '2008-03-21 12:34:56'
		));
		unset($expected['User']['passwd']); unset($results['User']['passwd']);
		$this->assertEqual($results, $expected);
	}
}
?>